﻿using System.Data.Entity.ModelConfiguration;
using yiCommerce.Core.Domain.Brands;

namespace yiCommerce.Data.Mapping.Brands
{
    public class ProductBrandMapping : EntityTypeConfiguration<ProductBrand>
    {
        public ProductBrandMapping()
        {
            this.ToTable("Product_Brand_Mapping");
            this.HasKey(pm => pm.Id);

            this.HasRequired(pm => pm.Brand)
                .WithMany()
                .HasForeignKey(pm => pm.BrandId);


            this.HasRequired(pm => pm.Product)
                .WithMany(p => p.ProductBrands)
                .HasForeignKey(pm => pm.ProductId);
        }
    }
}